package com.itheima.d5_Api_Math;

public class demo {
    public static void main(String[] args) {
        //1.绝对值abs
        int a = -100;
        System.out.println(Math.abs(a));

        //2.向上取整
        double b = 11.611144;
        System.out.println(Math.ceil(b));//12
        System.out.println(Math.ceil(4.0000));//4
        System.out.println(Math.ceil(4.0001));//5

        //3.向下取整
        System.out.println(Math.floor(4.99999));//4

        //4.指数次方
        System.out.println(Math.pow(2,3));//8

        //5.四舍五入
        System.out.println(Math.round(5.49999));//5
        System.out.println(Math.round(5.60001));//6

        //6.随机数
        System.out.println(Math.random());//0.0-1.0(包前不包后)

        /*
         * 取3-9之间的随机数 （0--6）+3
         * （0-1）*7+3
         */
        System.out.println((int) (Math.random() * 7) + 3);

    }
}
